<template>
  <el-form>
    <el-form-item label="中文名">
      <el-input v-model.trim="user.name"/>
    </el-form-item>
    <el-form-item label="英文名">
      <el-input v-model.trim="user.enName"/>
    </el-form-item>
    <el-form-item label="个人简介">
      <el-input type="textarea" v-model.trim="user.description"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">修改</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import Request from "@/api/request";

export default {
  props: {
    user: {
      type: Object,
      default: () => {
        return {
          name: '',
          enName: '',
          description: '请填写个人简介'
        }
      }
    }
  },
  methods: {
    submit() {
      Request.put("/user", this.user).then(res => {
        if (res === true) {
          this.$message({
            message: '修改成功',
            type: 'success',
            duration: 5 * 1000
          })
        } else {
          this.$message({
            message: '修改失败',
            type: 'error',
            duration: 5 * 1000
          })
        }
      })

    }
  }
}
</script>
